<?php


namespace App\Api\Models;


use Illuminate\Database\Eloquent\Model;

class CmcGoodsCart extends Model
{
    protected $table='cmc_goods_carts';

    //购物车添加
    static public function addCart($goodscart)
    {
        return CmcGoodsCart::insert($goodscart);
    }

    //验证是否有数据
    static public function onceCart($gid,$uid)
    {
        return CmcGoodsCart::where('goods_id',$gid)->where('uid',$uid)->count();
    }

    //查询购物车数据
    static public function allCart($uid)
    {
        return CmcGoodsCart::where('uid',$uid)->get()->toArray();
    }

    //获取购物车商品价钱
    static public function getCartprice($id)
    {
        return CmcGoodsCart::where('id',$id)->first('goods_price')->toArray()['goods_price'];
    }
}